---
id: cancellation
title: Interrupt a Workflow - PHP SDK
sidebar_label: Interrupt a Workflow
slug: /develop/php/cancellation
toc_max_heading_level: 2
keywords:
  - cancellation
  - php sdk
  - overview
tags:
  - Workflows
  - PHP SDK
  - Temporal SDKs
description: Learn how to effectively cancel an Activity from a Workflow using Heartbeats and Heartbeat Timeouts. Discover the essential steps for handling Activity cancellations to ensure proper Workflow management.
---

## Cancel an Activity from a Workflow {#cancel-an-activity}

Canceling an Activity from within a Workflow requires that the Activity Execution sends Heartbeats and sets a Heartbeat Timeout.
If the Heartbeat is not invoked, the Activity cannot receive a cancellation request.
When any non-immediate Activity is executed, the Activity Execution should send Heartbeats and set a [Heartbeat Timeout](/encyclopedia/detecting-activity-failures#heartbeat-timeout) to ensure that the server knows it is still working.

When an Activity is canceled, an error is raised in the Activity at the next available opportunity.
If cleanup logic needs to be performed, it can be done in a `finally` clause or inside a caught cancel error.
However, for the Activity to appear canceled the exception needs to be re-raised.

:::note

Unlike regular Activities, [Local Activities](/activities#local-activity) can be canceled if they don't send Heartbeats.
Local Activities are handled locally, and all the information needed to handle the cancellation logic is available in the same Worker process.

:::
